package com.woniuxy.config.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 马宇航
 * @Description: 广播交换机配置类
 * @DateTime: 25/10/27/星期一 11:01
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class FanoutExchangeConfig {
    @Bean
    public Queue emailQueue() {
        return new Queue("emailQueue");
    }
    @Bean
    public Queue emsQueue() {
        return new Queue("emsQueue");
    }
    //配置交换机
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("fanoutExchange");
    }
    //banding交换机和队列
    @Bean
    public Binding emailQueueBinding() {
        //手动把队列和交换机进行11绑定
        return BindingBuilder.bind(emailQueue()).to(fanoutExchange());
    }
    @Bean
    public Binding emsQueueBinding() {
        return BindingBuilder.bind(emsQueue()).to(fanoutExchange());
    }
}
